package com.kyz.speechsdk.engine;

import android.util.Log;


import com.kyz.speechsdk.engine.abstracts.BaseUnderstandingEngine;
import com.kyz.speechsdk.engine.entity.EngineResult;
import java.util.concurrent.Executors;

/**
 * create by ZhongZihao on 2020/12/29
 * 知识库后台语义匹配
 */
public class RobotServerEngine extends BaseUnderstandingEngine {
    private static final String TAG = "TAG_RobotServerEngine";

    private RobotServerEngine(Builder builder) {
        setNextEngine(builder.engine);
    }

    @Override
    protected void requestTextUnderstand(String text, boolean isChainUnderstand) {
        Executors.newCachedThreadPool().execute(() -> {
            boolean b = false;
            if (b) {
                onEngineResult(new EngineResult("---- RobotServerEngine ---- text : " + text, EngineResult.ENGINE_SERVER));
                Log.d("tag", "----- RobotServerEngine---- text : " + text);
            } else {
                if (isChainUnderstand) {
                    nextEngineChainTextUnderstand(text);
                }
            }

        });
    }

    public static class Builder {
        private BaseUnderstandingEngine engine;

        public Builder setNextEngine(BaseUnderstandingEngine engine) {
            this.engine = engine;
            return this;
        }

        public RobotServerEngine build() {
            return new RobotServerEngine(this);
        }
    }


    @Override
    public void destoryEngine() {
        super.destoryEngine();
        Log.i(TAG, "destoryEngine: RobotServerEngine.....");

    }
}
